package com.example.base;

import java.time.LocalDate;
import java.util.Date;

/**
 * 面向过程：先确定操作数据的过程，再决定数据的结构
 * 面向对象：先决定数据的结构，在考虑操作数据的算法；问题规模大的时候，可以将方法封装到对象里面，更易于找 bug
 */
public class ObjectTest {
    public static void main(String[] args) {
        //java类库设计者将保存时间和时间点命名分开：Date 和 LocalDate
        System.out.println(new Date());//Tue Nov 30 19:51:24 CST 2021

        LocalDate newYearsEve = LocalDate.now();
        int year = newYearsEve.getYear();
        int month = newYearsEve.getMonthValue();
        int day = newYearsEve.getDayOfYear();
        System.out.println("当前日期");
        System.out.println("year: " + year +
                " month: " + month +
                " day: " + day);

        LocalDate aThousandDaysLater = newYearsEve.plusDays(1000);
        int year2 = aThousandDaysLater.getYear();
        int month2 = aThousandDaysLater.getMonthValue();
        int day2 = aThousandDaysLater.getDayOfYear();
        System.out.println("1000天以后");
        System.out.println("year: " + year2 +
                " month: " + month2 +
                " day: " + day2);

    }
}
